package com.ruoyi.web.controller.mes;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.ruoyi.web.domain.mes.MesCustom;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.web.domain.mes.MesTonnage;
import com.ruoyi.web.service.IMesTonnageService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;
import org.springframework.web.multipart.MultipartFile;

/**
 * 吨位系数Controller
 * 
 * @author levicash
 * @date 2024-05-20
 */
@RestController
@RequestMapping("/mes/mestonnage")
public class MesTonnageController extends BaseController
{
    @Autowired
    private IMesTonnageService mesTonnageService;

    /**
     * 查询吨位系数列表
     */
    @GetMapping("/list")
    public TableDataInfo list(MesTonnage mesTonnage)
    {
        startPage();
        List<MesTonnage> list = mesTonnageService.selectMesTonnageList(mesTonnage);
        return getDataTable(list);
    }

    /**
     * 导出吨位系数列表
     */
    @Log(title = "吨位系数", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, MesTonnage mesTonnage)
    {
        List<MesTonnage> list = mesTonnageService.selectMesTonnageList(mesTonnage);
        ExcelUtil<MesTonnage> util = new ExcelUtil<MesTonnage>(MesTonnage.class);
        util.exportExcel(response, list, "吨位系数数据");
    }

    /**
     * 获取吨位系数详细信息
     */
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(mesTonnageService.selectMesTonnageById(id));
    }

    /**
     * 新增吨位系数
     */
    @Log(title = "吨位系数", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody MesTonnage mesTonnage)
    {
        return toAjax(mesTonnageService.insertMesTonnage(mesTonnage));
    }

    /**
     * 批量新增吨位系数
     */
    @Log(title = "吨位系数", businessType = BusinessType.IMPORT)
    @PostMapping("/batchAdd")
    public AjaxResult batchAdd(@RequestBody List<MesTonnage> mesTonnagelist)
    {
        return toAjax(mesTonnageService.insertMesTonnageBatch(mesTonnagelist));
    }

    /**
     * 修改吨位系数
     */
    @Log(title = "吨位系数", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody MesTonnage mesTonnage)
    {
        return toAjax(mesTonnageService.updateMesTonnage(mesTonnage));
    }

    /**
     * 删除吨位系数
     */
    @Log(title = "吨位系数", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(mesTonnageService.deleteMesTonnageByIds(ids));
    }
}
